<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'app',
  components: {
    
  },
  data(){
    return {
      
    }
  },
  mounted(){
    if(this.$cookie.get('userInfo')!=null){
      this.getUser();
      this.getCartCount();
    }
  },
  methods:{
    getUser(){
        this.$store.dispatch('saveUserName',JSON.parse(this.$cookie.get('userInfo')).username);
      // this.axios.get('/user').then((res={})=>{
      //   this.$store.dispatch('saveUserName',res.username);
      // })
    },
    getCartCount(){
      this.axios.get('/carts/products/'+JSON.parse(this.$cookie.get("userInfo")).id).then(res=>{
        this.$store.dispatch('saveCartCount',res);
      })
    }
  }
}
</script>

<style lang="scss">
@import './assets/scss/reset.scss';
@import './assets/scss/config.scss';
@import './assets/scss/button.scss';
</style>
